set more off

set seed 12262021
*********************
****** ALLIANCES ****
*********************
use "Alliance_RepData.dta", clear

***BASE MODELS

**Pooled

logit violate solschangeNA_3 dembothNA time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
estsimp logit violate solschangeNA_3 dembothNA time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
*effect of solsch compared to no solsch
setx time mean timesquare mean timecube mean dembothNA 1
*note: setting dembothNA to 1 (mode)// this is update based on new data--previously set to 0
setx solschangeNA_3 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx time mean timesquare mean timecube mean solschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr3)
setx dembothNA 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b2 b3 b4 b5 b6  pr1 pr2 rr1 pr3 pr4 rr2


**Interaction

logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
estsimp logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
setx time mean timesquare mean timecube mean
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr2)
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 1
simqi, prval(1) genpr(pr3)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 1
setx dembothNA 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-solsch in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


***CONTROL 1 MODELS

**Pooled

logit violate solschangeNA_3 dembothNA abscincperch1_10 decthreat1_10 allyCW1 postCW time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
estsimp logit violate solschangeNA_3 dembothNA abscincperch1_10 decthreat1_10 allyCW1 postCW time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
*effect of solsch compared to no solsch
setx time mean timesquare mean timecube mean dembothNA 1 abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0
*NOTE: setting dembothNA to 1 (mode)// this is update based on new data
setx solschangeNA_3 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx time mean timesquare mean timecube mean abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0 solschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr3)
setx dembothNA 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 pr2 pr1 rr1 pr3 pr4 rr2


**Interaction

logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 abscincperch1_10 decthreat1_10 allyCW1 postCW time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
estsimp logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 abscincperch1_10 decthreat1_10 allyCW1 postCW time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
setx time mean timesquare mean timecube mean abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr2)
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 1
simqi, prval(1) genpr(pr3)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 1
setx dembothNA 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-solsch in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 2 MODELS

**Pooled

logit violate solschangeNA_3 dembothNA abscincperch1_10 decthreat1_10 allyCW1 postCW mixedalliance nomicoop estmode milinst abscincperch2_10 incthreat2_10 regtransNB solschangeNB_3  time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
*NOTE: need to drop regtransB because otherwise Clarify won't estimate
estsimp logit violate solschangeNA_3 dembothNA abscincperch1_10 decthreat1_10 allyCW1 postCW mixedalliance nomicoop estmode milinst abscincperch2_10 incthreat2_10 solschangeNB_3 time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
*effect of solsch compared to no solsch
setx time mean timesquare mean timecube mean dembothNA 1 abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0  mixedalliance 0 nomicoop 1 estmode 1 milinst 0 abscincperch2_10 0 incthreat2_10 0 solschangeNB_3 0
*NOTE: setting dembothNA to 1 (mode)// this is update based on new data
setx solschangeNA_3 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx time mean timesquare mean timecube mean abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0  mixedalliance 0 nomicoop 1 estmode 1 milinst 0 abscincperch2_10 0 incthreat2_10 0 solschangeNB_3 0 solschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr3)
setx dembothNA 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 pr1 pr2 rr1 pr3 pr4 rr2


**Interaction

logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 abscincperch1_10 decthreat1_10 allyCW1 postCW mixedalliance nomicoop estmode milinst abscincperch2_10 incthreat2_10 regtransNB solschangeNB_3 time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
*note: there are no regtrans in B that lead to violation; Clarify won't work; drop regtrans in B from analysis
estsimp logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 abscincperch1_10 decthreat1_10 allyCW1 postCW mixedalliance nomicoop estmode milinst abscincperch2_10 incthreat2_10 solschangeNB_3 time timesquare timecube if regtransNA==0, robust cluster (atopidphase)
setx time mean timesquare mean timecube mean abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0  mixedalliance 0 nomicoop 1 estmode 1 milinst 0 abscincperch2_10 0 incthreat2_10 0 solschangeNB_3 0
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr2)
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 1
simqi, prval(1) genpr(pr3)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 1
setx dembothNA 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-solsch in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg



********************************
********* UNGA *****************
********************************
use "UNGA_RepData.dta", clear
tsset ccode year

***BASE MODELS

**Pooled

xtreg logvotech solsch demboth if regtrans==0, i(ccode) fe robust cluster(ccode)

**Interaction

xtreg logvotech solsch##demboth if regtrans==0, i(ccode) fe robust cluster(ccode)
margins, dydx(solsch) at(demboth==1) at(demboth==0) post
margins, coeflegend
test  _b[1.solsch:1bn._at] =  _b[1.solsch:2._at]
xtreg logvotech solsch##demboth if regtrans==0, i(ccode) fe robust cluster(ccode)
margins, dydx(demboth) at(solsch==1) at(solsch==0) post
margins, coeflegend
test   _b[1.demboth:1bn._at] =   _b[1.demboth:2._at]


*** CONTROL 1 MODEL
*Note: this is actually control 2 in the do files

** Pooled

xtreg logvotech solsch demboth allyCW CWend abscincperch10 gdpdrop5 logrealGDPpcG if regtrans==0, i(ccode) fe robust cluster(ccode)

**Interaction

xtreg logvotech solsch##demboth allyCW CWend abscincperch10 gdpdrop5 logrealGDPpcG if regtrans==0, i(ccode) fe robust cluster(ccode)
margins, dydx(solsch) at(demboth==1) at(demboth==0) post
margins, coeflegend
test  _b[1.solsch:1bn._at] =  _b[1.solsch:2._at]
xtreg logvotech solsch##demboth allyCW CWend abscincperch10 gdpdrop5 logrealGDPpcG if regtrans==0, i(ccode) fe robust cluster(ccode)
margins, dydx(demboth) at(solsch==1) at(solsch==0) post
margins, coeflegend
test   _b[1.demboth:1bn._at] =   _b[1.demboth:2._at]


*******************************
********* SANCTIONS ***********
*******************************
use "Sanctions_RepData.dta", clear

******** ALL CASES, W/ US

***BASE MODELS

**Pooled

logit sendercap2 ssolsch4 sdemmboth monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 
*effect of solsch compared to no solsch
estsimp logit sendercap2 ssolsch4 sdemmboth monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid)
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1
*note: setting demboth to 1 (mode)
setx ssolsch4 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx monthnum mean monthnum2 mean monthnum3 mean ssolsch4 0
setx sdemmboth 0
simqi, prval(1) genpr(pr3)
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b2 b3 b4 b5 b6 pr1 pr2 rr2 pr3 pr4 rr1

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 

**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 1

**Pooled

logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster (caseid)
*effect of solsch compared to no solsch
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1 abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0
*note: setting demboth to 1 (mode)
setx ssolsch4 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 ssolsch4 0
setx sdemmboth 0
simqi, prval(1) genpr(pr3)
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 pr1 pr2 rr2 pr3 pr4 rr1

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 

**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 2

**Pooled

logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster (caseid)
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1 abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0
*note: setting demboth to 1 (mode)
setx ssolsch4 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
simqi, prval(1) genpr(pr2)
*effect of solsch compared to no ldrtrans
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0 ssolsch4 0
setx sdemmboth 0
simqi, prval(1) genpr(pr3)
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 pr1 pr2 rr2 pr3 pr4 rr1

**Interaction
logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if sregtrans==0, robust cluster(caseid) 
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg

******** ALL CASES, NO US

***BASE MODELS

**Pooled

logit sendercap2 ssolsch4 sdemmboth monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid)
*effect of solsch compared to no solsch
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1
*note: setting demboth to 1 (mode)
setx ssolsch4 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx monthnum mean monthnum2 mean monthnum3 mean ssolsch4 0
setx sdemmboth 0
simqi, prval(1) genpr(pr3)
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b2 b3 b4 b5 b6 pr1 pr2 rr2 pr3 pr4 rr1


**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 

**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 1

**Pooled

logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster (caseid)
*effect of solsch compared to no solsch
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1 abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0
*note: setting demboth to 1 (mode)
setx ssolsch4 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1 abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 ssolsch4 0
setx sdemmboth 0
simqi, prval(1) genpr(pr3)
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 pr1 pr2 pr2 rr1 pr3 pr4 rr2


**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg



*** CONTROL 2

**Pooled

logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster (caseid)
*effect of solsch compared to no solsch
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1 abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0
*note: setting demboth to 1 (mode)
setx ssolsch4 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
simqi, prval(1) genpr(pr2)
gen rr1 = pr2 / pr1
sumqi rr1
sumqi rr1, level(90)
*effect of dem vs nondem
setx monthnum mean monthnum2 mean monthnum3 mean sdemmboth 1 abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0 ssolsch4 0
setx sdemmboth 0
simqi, prval(1) genpr(pr3)
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
gen rr2= pr3/pr4
sumqi rr2
sumqi rr2, level(90)

capture drop pr1 pr2 rr1 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 pr3 pr4 rr2


**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb abscincperch10A gdpdrop5A allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if US==0 & sregtrans==0, robust cluster(caseid) 
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg sdiff nsdiff margreg


*******************************
********* TRADE  **************
*******************************

**Restricted sample
use "Trade_RepData.dta", clear
tsset ddyad year

***BASIC

**Pooled

xtreg MRdv_rest L.solschdumA_3 L.dembothA if L.regtransA==0,fe cluster(ddyad) robust

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA if L.regtransA==0,fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA if L.regtransA==0,fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]


***CONTROL 1

**Pooled

xtreg MRdv_rest L.solschdumA_3 L.dembothA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict if L.regtransA==0,fe cluster(ddyad) robust

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict if L.regtransA==0,fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict if L.regtransA==0,fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]

***CONTROL 2

**Pooled

xtreg MRdv_rest L.solschdumA_3 L.dembothA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict L.gattwto L.pta L.solschdumB_3 L.allyCW2 L.conflictb L.gdpln_a L.gdpln_b if L.regtransA==0,fe cluster(ddyad) robust

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict L.gattwto L.pta L.solschdumB_3 L.allyCW2 L.conflictb L.gdpln_a L.gdpln_b if L.regtransA==0,fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict L.gattwto L.pta L.solschdumB_3 L.allyCW2 L.conflictb L.gdpln_a L.gdpln_b if L.regtransA==0,fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]






